<#assign base=request.contextPath />
<#import "/tags/select.ftl" as k />
<!DOCTYPE html>
<html>
<head>
  <base href="${base}">	
  <meta charset="utf-8">
  <title>列表</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="${base}/layuiadmin/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="${base}/css/my.css" media="all">
</head>

<body>
  	<div class="layui-form three" lay-filter="LAY-form-list" style="padding: 20px 30px 0 0;">
  		<input type="hidden" name="oid" value="${(article.oid)!}">
  		<div class="layui-form-item flex1">
			<label class="layui-form-label required">文章标题</label>
			<div class="layui-input-block">
				<input type="text" name="title" value="${(article.title)!}" lay-verify="required" class="layui-input" placeholder="文章标题" />
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label required">文章类型</label>
			<div class="layui-input-block">
				<select name="type.dicId" lay-verify="required" lay-search>
	    			<option value="">---请选择---</option>
	      			<@dicts itemName="文章类型">
	      				<#list items as item>
	      					<#if ((article.type.dicId)!0) == item.dicId>
	      						<option value="${item.dicId}" selected>${item.itemValue}</option>
	      					<#else>
	      						<option value="${item.dicId}">${item.itemValue}</option>
	      					</#if>  				
	      				</#list>
	      			</@dicts>
      			</select>
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label required">发表时间</label>
			<div class="layui-input-block">
				<input type="text" name="ctime" value="${(article.ctime?string('yyyy-MM-dd'))!}" id="ctime" lay-verify="required" class="layui-input" placeholder="发表时间" />
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label required">状态</label>
			<div class="layui-input-block">
				<@k.select id="status" datas=[[0, '禁用'], [1, '激活']] value='${(article.status)!}'/>
			</div>
		</div>
		<div class="layui-form-item flex1">
			<label class="layui-form-label required">文章内容</label>
			<div class="layui-input-block">
				<textarea id="content" name="content" style="width:100%;height:280px;">${(article.content)!}</textarea>
				<script id="editor" type="text/plain" style="width:100%;height:280px;"></script>
			</div>
		</div>
	    <div class="layui-form-item layui-hide">
	      	<input type="button" lay-submit lay-filter="LAY-form-submit" id="LAY-form-submit" value="确认添加">
	      	<input type="button" lay-submit lay-filter="LAY-form-edit" id="LAY-form-edit" value="确认编辑">
	    </div>
  	</div>

  <script src="${base}/js/lib/jquery-1.11.3.min.js"></script>
  <script src="${base}/js/commons.js"></script>
  <script src="${base}/layuiadmin/layui/layui.js"></script>
  <script type="text/javascript" charset="utf-8" src="${base}/ueditor/ueditor.config.js"></script>
  <script type="text/javascript" charset="utf-8" src="${base}/ueditor/ueditor.all.min.js"> </script>
  <script type="text/javascript" charset="utf-8" src="${base}/ueditor/lang/zh-cn/zh-cn.js"></script>
  <script>
  	layui.config({
    	base: '${base}/layuiadmin/' //静态资源所在路径
  	}).extend({
    	index: 'lib/index'
  	}).use(['index', 'form', 'laydate'], function(){
    	var form = layui.form;
    	layui.laydate.render({elem: '#ctime', trigger:'click'});
    	
    	//创建富文本框
		var ue = UE.getEditor('content');
		ue.ready(function() {
		    ue.setContent('${(article.content)!}');
		});
    	
    	//监听提交
    	form.on('submit(LAY-form-submit)', function(data) {
    		data.field.content = ue.getContent();
      		var index = parent.layer.getFrameIndex(window.name);      		
      		$$.ajax({
      			url: '${base}/blog/article/save',
      			data: data.field,
      			success: function(json) {
      				parent.layui.table.reload('LAY-table');
      	      		parent.layer.close(index);
      			}
      		});
    	});
  	})
  </script>
</body>
</html>